<?php
/**
 * Load styles and scripts
 * 
 */
//include 'theme_walker.php';
//include 'admin/Larch_admin.php';
//include 'admin/theme_options.php';
if(  class_exists( 'TitanFramework')){
include 'admin/titan_admin_options.php';
}
include 'inc/shortcode.php';
include 'inc/woocommerce_override.php';

function larch_scripts(){
	wp_enqueue_style('bootstrap.min', get_stylesheet_directory_uri().'/assets/css/bootstrap.min.css');
	wp_enqueue_script('bootstrap.min', get_template_directory_uri().'/assets/js/bootstrap.min.js', array('jquery'));
	if(!is_admin()){
		wp_enqueue_style('style', get_stylesheet_uri());
		wp_enqueue_script('jquery.mixitup.min',  get_template_directory_uri().'assets/js/mixitup-1.5.5/juery.mixitup.min.js',array('jquery'));
		wp_enqueue_script('larch-jquery',  get_template_directory_uri().'assets/js/larch-jquery.js',array('jquery','jquery-mixitup-min'));
	}
	wp_enqueue_style('dynamic-css',
                 admin_url('admin-ajax.php').'?action=dynamic_css');
}
function dynaminc_css() {
  require(get_template_directory().'/assets/css/dynamic-style.php');
  exit;
}
add_action('wp_ajax_dynamic_css', 'dynaminc_css');
add_action('wp_ajax_nopriv_dynamic_css', 'dynaminc_css');
function larch_admin_scripts(){
	wp_enqueue_style('bootstrap.min', get_stylesheet_directory_uri().'/assets/css/bootstrap.min.css');
	wp_enqueue_script('bootstrap.min', get_template_directory_uri().'/assets/js/bootstrap.min.js', array('jquery'));
	wp_enqueue_style( 'thickbox' ); // Stylesheet used by Thickbox
    wp_enqueue_script( 'thickbox' );
    wp_enqueue_script( 'media-upload' );
    wp_enqueue_script( 'theme.admin', get_template_directory_uri() . '/admin/theme.admin.js', array( 'thickbox', 'media-upload' ) );
}
add_action('admin_enqueue_scripts','larch_admin_scripts');
add_action( 'wp_enqueue_scripts', 'larch_scripts' );

/**
 * Setting default content width
 * 
 */
if(!isset($content_width)){
	$content_width = 474;
}

if(!function_exists( 'larch_setup')){
	function larch_setup(){
		//load text domain
		load_theme_textdomain('larch',  get_template_directory().'/lang');
		add_theme_support('post-thumbnails');
		set_post_thumbnail_size(672,372,true);
		add_image_size('larch-full-width', 1038, 576, true);
		//register navigations
		register_nav_menus(array(
			'primary' => __('Main menu','larch'),
			'secondary' => __('Sidebar menu','larch'),
			'ternary' => ('Other navigation on a single page'),
		));
		add_theme_support('html5',array(
			'search-form','comment-form','comment-list'
		));
		add_theme_support('post-formats',array(
			'image','video','link','gallery'
		));
		add_theme_support('custom-background',array('default-color'=>'f5f5f5'));
		add_theme_support('custom-header');
	}
}
add_action('after_setup_theme','larch_setup');
if(!function_exists( 'register_navs')){
	function register_navs(){
		register_sidebar(array(
			'name'=>__('Main Navigation','larch'),
			'id'=>'pseudo-menu',
			'description'=>__('navigation','larch'),
		));
		register_sidebar(array(
			'name'=>__('Shop Sidebar','larch'),
			'id'=>'sidebar-1',
			'description'=>__('sidebar in the shop page','larch')
		));
		register_sidebar(array(
			'name'=>__('Left Sidebar','larch'),
			'id'=>'sidebar-2',
			'description'=>__('sidebar in left of the page','larch')
		));
		register_sidebar(array(
			'name'=>__('Right Sidebar','larch'),
			'id'=>'sidebar-3',
			'description'=>__('additional sidebar for the right sidebar','larch')
		));
	}
}
add_action('widgets_init','register_navs');
